<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jquery.js"></script>
    <style>
        ul{
            display: flex;
        }
        li{
            list-style: none;
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <ul class="box">
        <li>☆</li>
        <li>☆</li>
        <li>☆</li>
        <li>☆</li>
        <li>☆</li>
    </ul>
    <script>
        $.fn.extend({
            good(){
                let s="★";
                let k="☆";
                this.children().on("mouseenter",function(){
                    $(this).text(s).prevAll().text(s).end().nextAll().text(k)
                    $(this).on("click",function(){
                        $(this).addClass("flag").siblings().removeClass("flag")
                    })
                })
                this.on("mouseleave",()=>{
                    this.children().text(k)
                    this.find("[class='flag']").text(s).prevAll().text(s).end().nextAll().text(k)
                })
            }
        })

        $(function(){
            $(".box").good()
        })
    </script>
</body>
</html>